<template>
  <div class="container">
    <div class="header">
      <div class="back-button" @click="goBack">&#10094;</div>
      <div class="title">选择取消原因</div>
    </div>
    <div class="content">
      <!-- 平台相关选项 -->
      <h2 class="platform-sub-title">平台相关</h2>
      <view class="radio-list">
        <u-radio-group v-model="value" @change="radioGroupChange">
          <!-- 平台相关的取消原因选项 -->
          <div v-for="(item, index) in platformList" :key="index" class="radio-item">
            <span>{{ item.name }}</span>
            <u-radio :name="item.name" :disabled="item.disabled" class="radio-button"></u-radio>
          </div>
        </u-radio-group>
      </view>

      <!-- 司机相关选项 -->
      <h2 class="platform-sub-title">司机相关</h2>
      <view class="radio-list">
        <u-radio-group v-model="value" @change="radioGroupChange">
          <!-- 司机相关的取消原因选项 -->
          <div v-for="(item, index) in driverList" :key="index" class="radio-item">
            <span>{{ item.name }}</span>
            <u-radio :name="item.name" :disabled="item.disabled" class="radio-button"></u-radio>
          </div>
        </u-radio-group>
      </view>
	  
	   <!-- 个人原因选项区域 -->
	        <h2 class="platform-sub-title">个人原因</h2>
	        <view class="radio-list">
	          <u-radio-group v-model="value" @change="radioGroupChange">
	            <!-- 个人原因的单选按钮 -->
	            <div v-for="(item, index) in personalList" :key="index" class="radio-item">
	              <span>{{ item.name }}</span>
	              <u-radio :name="item.name" :disabled="item.disabled" class="radio-button"></u-radio>
	            </div>
	          </u-radio-group>
	        </view>
	  
    </div>
  </div>
</template>

<script>
export default {
  name: 'CancelOrderPage',
  methods: {
    goBack() {
      // 实现返回逻辑
      this.$router.go(-1);
    }
  },
  data() {
  		return {
  			platformList: [
  				{
  					name: '平台派单太远',
  					disabled: false
  				},
  				{
  					name: '上车位置错误/找不到上车位置',
  					disabled: false
  				}
  			],
			driverList: [
			        { name: '司机迟到', disabled: false },
			        { name: '司机找不到乘客', disabled: false },
			        { name: '司机车辆故障', disabled: false },
			        { name: '司机个人原因', disabled: false },
			        { name: '司机健康问题', disabled: false },
			        { name: '司机不熟悉路线', disabled: false },
			        { name: '其他司机原因', disabled: false }
			      ],
			personalList: [
			        { name: '行程有变', disabled: false },
			        { name: '目的地有误', disabled: false },
			        { name: '选择其他出行工具', disabled: false }
			      ],
  			// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
  			value: 'orange',
  		};
  	},
  	methods: {
  		// 选中某个单选框时，由radio时触发
  		radioChange(e) {
  			// console.log(e);
  		},
  		// 选中任一radio时，由radio-group触发
  		radioGroupChange(e) {
  			// console.log(e);
  		}
  	},
	
}
</script>

<style scoped>
.container {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f4f4f4;
}
.header {
  background-color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.back-button {
  cursor: pointer;
  font-size: 24px;
  margin-right: 10px;
  position: absolute;
  left: 20px;
}
.title {
  font-size: 20px;
  font-weight: bold;
}
.content {
  padding: 20px;
}
/* 添加小标题的样式 */
.platform-sub-title {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin-bottom: 15px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 10px;
}

/* 添加单选按钮列表的样式 */
.radio-list {
  display: flex;
  flex-direction: column; /* 确保子元素垂直排列 */
}

.radio-item {
  display: flex;
  justify-content: space-between; /* 保持justify-content为space-between */
  align-items: center; /* 确保子元素垂直居中 */
  margin-bottom: 10px;
}

.radio-item span {
  flex: 1; /* 让文字占据剩余空间 */
  margin-right: 10px; /* 为文字和单选按钮之间添加一些间隔 */
}

.radio-button {
  /* 如果需要，可以添加一些样式来美化单选按钮 */
}
</style>
